﻿<StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            x:Class="MVVMBasic.View.Login.LoginForm"
            KeyDown="LoginForm_KeyDown"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:Controls="clr-namespace:Infrastructure.Controls;assembly=Infrastructure"
            xmlns:Controls1="clr-namespace:MVVMBasic.Controls"
            mc:Ignorable="d"
            d:DataContext="{d:DesignInstance Type=login:LoginInfo}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition />
        </Grid.RowDefinitions>

        <Controls:BusyIndicator x:Name="busyIndicator"
                                BusyContent="{Binding Path=ApplicationStrings.BusyIndicatorLoggingIn, Source={StaticResource ResourceWrapper}}"
                                IsBusy="{Binding IsLoggingIn}">
            <StackPanel Orientation="Vertical">
                <Controls1:CustomDataForm x:Name="loginForm"
                                          Padding="10,0,10,0"
                                          CurrentItem="{Binding}"
                                          IsEnabled="{Binding IsLoggingIn, Converter={StaticResource NotOperatorValueConverter}}"
                                          AutoEdit="True"
                                          CommandButtonsVisibility="None"
                                          HeaderVisibility="Collapsed"
                                          AutoGeneratingField="LoginForm_AutoGeneratingField"
                                          Style="{StaticResource LoginDataFormStyle}" />
            </StackPanel>
        </Controls:BusyIndicator>

        <StackPanel Grid.Row="1"
                    Grid.Column="1"
                    Orientation="Horizontal"
                    HorizontalAlignment="Right"
                    Margin="0,0,10,0">
            <Button x:Name="loginButton"
                    Content="{Binding Path=ApplicationStrings.OKButton, Source={StaticResource ResourceWrapper}}"
                    Click="LoginButton_Click"
                    Style="{StaticResource RegisterLoginButtonStyle}"
                    IsEnabled="{Binding Path=CanLogIn}" />
            <Button x:Name="loginCancel"
                    Content="{Binding Path=ApplicationStrings.CancelButton, Source={StaticResource ResourceWrapper}}"
                    Click="CancelButton_Click"
                    Style="{StaticResource RegisterLoginButtonStyle}" />
        </StackPanel>

        <StackPanel Grid.Row="1"
                    Grid.Column="0"
                    Style="{StaticResource RegisterLoginLinkPanelStyle}">
            <TextBlock Text="{Binding Path=ApplicationStrings.NotRegisteredYetLabel, Source={StaticResource ResourceWrapper}}"
                       Style="{StaticResource CommentStyle}" />
            <HyperlinkButton x:Name="registerNow"
                             Content="{Binding Path=ApplicationStrings.RegisterNowButton, Source={StaticResource ResourceWrapper}}"
                             Click="RegisterNow_Click"
                             IsEnabled="{Binding IsLoggingIn, Converter={StaticResource NotOperatorValueConverter}}" />
        </StackPanel>
    </Grid>
</StackPanel>